package com.neusoft.tijian.mapper;

import com.neusoft.tijian.dto.CalendarResponseDto;
import com.neusoft.tijian.dto.OrdersMapperDto;
import com.neusoft.tijian.po.Orders;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface OrdersMapper {
    //查询是否预约过（凡是有未归档的预约记录的用户，不能再次预约）
    @Select("select count(*) from orders where state=1 and userId=#{userId}")
    public int getOrdersByUserId(String userId);

    public List<CalendarResponseDto> listOrdersAppointmentNumber(List<OrdersMapperDto> list);

    /**
     * 创建体检预约订单
     */
    @Insert("INSERT INTO orders VALUES(null, #{orderDate}, #{userId}, #{hpId}, #{smId}, 1)")
    public int saveOrders(Orders orders);

    /**
     * 根据用户编号查询预约体检订单列表
     */
    public List<Orders> listOrdersByUserId(Orders orders);

    /**
     * 取消预约体检订单
     */
    @Delete("DELETE FROM orders WHERE orderId = #{orderId}")
    public int removeOrders(Integer orderId);

    @Select("SELECT * FROM orders WHERE orderId = #{orderId}")
    public Orders getOrdersById(Integer orderId);

}
